package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhPartyMembers;
import com.yinhe.system.service.IYhPartyMembersService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * YH_PARTY_MEMBERSController
 * 
 * @author yinhe
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/system/members")
public class YhPartyMembersController extends BaseController
{
    @Autowired
    private IYhPartyMembersService yhPartyMembersService;

    /**
     * 查询YH_PARTY_MEMBERS列表
     */
    @PreAuthorize("@ss.hasPermi('system:members:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhPartyMembers yhPartyMembers)
    {
        startPage();
        List<YhPartyMembers> list = yhPartyMembersService.selectYhPartyMembersList(yhPartyMembers);
        return getDataTable(list);
    }

    /**
     * 导出YH_PARTY_MEMBERS列表
     */
    @PreAuthorize("@ss.hasPermi('system:members:export')")
    @Log(title = "YH_PARTY_MEMBERS", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhPartyMembers yhPartyMembers)
    {
        List<YhPartyMembers> list = yhPartyMembersService.selectYhPartyMembersList(yhPartyMembers);
        ExcelUtil<YhPartyMembers> util = new ExcelUtil<YhPartyMembers>(YhPartyMembers.class);
        util.exportExcel(response, list, "YH_PARTY_MEMBERS数据");
    }

    /**
     * 获取YH_PARTY_MEMBERS详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:members:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhPartyMembersService.selectYhPartyMembersById(id));
    }

    /**
     * 新增YH_PARTY_MEMBERS
     */
    @PreAuthorize("@ss.hasPermi('system:members:add')")
    @Log(title = "YH_PARTY_MEMBERS", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhPartyMembers yhPartyMembers)
    {
        return toAjax(yhPartyMembersService.insertYhPartyMembers(yhPartyMembers));
    }

    /**
     * 修改YH_PARTY_MEMBERS
     */
    @PreAuthorize("@ss.hasPermi('system:members:edit')")
    @Log(title = "YH_PARTY_MEMBERS", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhPartyMembers yhPartyMembers)
    {
        return toAjax(yhPartyMembersService.updateYhPartyMembers(yhPartyMembers));
    }

    /**
     * 删除YH_PARTY_MEMBERS
     */
    @PreAuthorize("@ss.hasPermi('system:members:remove')")
    @Log(title = "YH_PARTY_MEMBERS", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhPartyMembersService.deleteYhPartyMembersByIds(ids));
    }
}
